<template>
  <div class="content">
    <!--收款条件列表弹窗-->
    <el-dialog
      v-dialogDrag
      :title="$t('market.recCondition')"
      model
      :visible.sync="isgatheringDialog"
      :close-on-click-modal="false"
      width="60%"
      :before-close="handleClose"
    >
      <div class="materiel-form">
        <span class="materiel-code">{{ $t('shop.name1') }}<!--名称--></span>
        <el-input v-model.trim="gathering.fname" class="input-width" size="mini" @keyup.enter.native="gatheringSearch" />
        <el-button size="mini" type="primary" @click="gatheringSearch">{{ $t('btn.search') }}</el-button>
      </div>
      <jc-table
        :table-data="gatheringDialogData"
        :table-header="gatheringDialogHeader"
        serial
        table-height="53vh"
        @clickRow="gatheringSelectRow"
      />
      <jc-pagination
        v-show="gathering.total > 0"
        :total="gathering.total"
        :page.sync="gathering.pageNum"
        :limit.sync="gathering.pageSize"
        @pagination="querytReccondition"
      />
    </el-dialog>
  </div>
</template>
<script>
import { queryViewItem } from '@/api/marketManage/marketOrder'

export default {
  data() {
    return {
      // 收款条件
      isgatheringDialog: true,
      gathering: {
        total: 0, // 总条目
        pageNum: 1, // 当前页
        pageSize: 20 // 每页显示多少条数据
      },
      gatheringDialogData: [],
      gatheringDialogHeader: [
        { label: this.$t('shop.fnumber'), prop: 'fnumber' },
        { label: this.$t('shop.name1'), prop: 'fname' },
        { label: this.$t('market.descrip'), prop: 'dataGroupName' }
      ],
      prodValue: { frecConditionIdName: '', frecConditionId: '', isgatheringDialog: true }
    }
  },
  created() {
    this.querytReccondition()
  },
  methods: {
    // 收款条件
    async querytReccondition() {
      this.isgatheringDialog = true
      const DATA = {
        viewName: 'SX_V_SAL_COLLECTION',
        ...this.gathering
      }
      const { data: RES } = await queryViewItem(DATA)
      this.gatheringDialogData = RES.list
      this.gathering.total = RES.total
    },
    gatheringSearch() {
      this.gathering.pageNum = 1
      this.querytReccondition()
    },
    // 选择收款条件
    gatheringSelectRow(item) {
      this.$emit('gathering', item)
    },
    // 关闭前回调
    handleClose() {
      this.prodValue.isgatheringDialog = false
      this.$emit('gathering', this.prodValue)
    }
  }
}
</script>
<style scoped lang="scss">
.content {
  @include listBom;
}
</style>

